package com.lianzhihui.romeex.adapter;

import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import androidx.annotation.Nullable;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.lianzhihui.romeex.R;

import java.util.ArrayList;
import java.util.List;

/**
 * Description:
 * Author:         RAMON
 * CreateDate:     2021/3/30 15:00
 * UpdateUser:
 * UpdateDate:
 * UpdateRemark:
 * Version:
 */
public class IPFSMadeAdapter extends BaseQuickAdapter<Object, BaseViewHolder> {

    public IPFSMadeAdapter(@Nullable List<Object> data) {
        super(R.layout.item_ipfs_made_layout, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, Object item) {

        helper.setText(R.id.tv_month, "");
        TextView monthTv = helper.getView(R.id.tv_month);
        LinearLayout root = helper.getView(R.id.ll_root);

        RecyclerView recyclerView = helper.getView(R.id.recyclerView);
        ArrayList a = new ArrayList<>();
        a.add(new Object());
        a.add(new Object());
        a.add(new Object());
        a.add(new Object());
        IPFSMadeMonthAdapter adapter = new IPFSMadeMonthAdapter(a);
        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(mContext);
        linearLayoutManager.setOrientation(RecyclerView.VERTICAL);
        recyclerView.setLayoutManager(linearLayoutManager);
        recyclerView.setAdapter(adapter);

        monthTv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (recyclerView.getVisibility() == View.VISIBLE) {

                    recyclerView.setVisibility(View.GONE);
                    ViewGroup.LayoutParams lp = root.getLayoutParams();
                    lp.height =  ViewGroup.LayoutParams.WRAP_CONTENT;

                    root.setLayoutParams(lp);

                } else {
                    recyclerView.setVisibility(View.VISIBLE);

                    ViewGroup.LayoutParams lp =
                            root.getLayoutParams();
                    lp.height = ViewGroup.LayoutParams.WRAP_CONTENT;

                    root.setLayoutParams(lp);
                }


            }
        });

    }
}
